$(function () {
    checkLoginStatus();
    getData();
    function getData() {

        var option = {
            url: HOST + '/admin/confirm_order.php',
            data: {
                getType: 'confirm',
                user: LsyCookie.getItem('loginUserName')
            }
        };
        request(option).then(function (res) {
            createProListHtml(res);
        });
    }

    function createProListHtml(data) {
        var str = '';
        var num = 0;
        var name = data[0].username;
        data.forEach(function (item) {
            str +=
                '<li data-id = "' + item.id + '">'
                + '<a href = "javascript:;">'
                + '<img src="' + item.img_src + '" alt = "玮兰商城">'
                + '</a>'
                + '<a href = "javascript:;">'
                + '<h3>' + item.title + '</h3>'
                + '</a>'
                + '<p>颜色：蓝白</p>'
                + '<p>材质：3E 椰梦维</p>'
                + '<div>'
                + '<b>￥' + item.price + '</b>'
                + '<i>x' + item.num + '</i>'
                + '</div>'
                + '</li>';
            num += item.price*item.num;
        });
        if (name.length > 6) {
            name = name.substr(0, 6) + '...';
        }
        $('#name').html(name);
        $('#list').html(str);
        $('#Quantity').html(data.length);
        $('#num').html(num);
    }

    $('#submit').tap(function () {
        window.location.href = '../html/pay.html';
    });
})